Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Human readable error when selecting wrong security protocol #43

Conversation

gasper-vrhovsek
Copy link
Contributor

@gasper-vrhovsek gasper-vrhovsek commented Nov 15, 2017

This change modifies the error message returned from nuage when selecting
the wrong security protocol. The old error message was:

wrong status line: "\x15\x03\x03\x00\x02\x02"

which was not informative to the end user.

@miq-bot bug

/cc @miha-plesko @gberginc

@miq-bot
Copy link
Member

miq-bot commented Nov 15, 2017

@gasper-vrhovsek unrecognized command 'bug', ignoring...

Accepted commands are: add_label, assign, close_issue, move_issue, remove_label, rm_label, set_milestone

@gasper-vrhovsek
Copy link
Contributor Author

@miq-bot add_label bug

@miq-bot miq-bot added the bug label Nov 15, 2017
Copy link
Contributor

@miha-plesko miha-plesko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gasper-vrhovsek totally a step in the right direction 👍 , but please simplifiy it a bit.

@@ -92,10 +94,10 @@ def verify_api_credentials(options = {})
with_provider_connection(options) {}
true
rescue => err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please either don't touch the rescue block if you don't need to 😉 or do it properly, because currently it looks like this 🤢 :

rescue => err
	_log.error("Error Class=#{err.class.name}, Message=#{err.message}")
	miq_exception = translate_exception(err)
	raise unless miq_exception

	raise miq_exception
end

which could be simplified into:

rescue => err
	_log.error("Error Class=#{err.class.name}, Message=#{err.message}")
	raise translate_exception(err)
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miha-plesko i have noticed this block of code was refactored in #40
I think it is best i revert my change here and wait for mergeing of code from the linked PR. Do you agree?

@@ -47,6 +47,8 @@ def translate_exception(err)
MiqException::MiqHostError.new "Socket error: #{err.message}"
when MiqException::MiqInvalidCredentialsError, MiqException::MiqHostError
err
when Net::HTTPBadResponse
Net::HTTPBadResponse.new "Login failed due to a bad hostname and/or port and/or security protocol."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I suggest a simple Login failed due to bad security protocol, hostname or port.?

@gasper-vrhovsek gasper-vrhovsek force-pushed the feature/security_protocol_pretty_error branch from 045482d to 8a272b6 Compare November 20, 2017 13:15
@gberginc
Copy link
Contributor

@miha-plesko i have noticed this block of code was refactored in #40
I think it is best i revert my change here and wait for mergeing of code from the linked PR. Do you agree?

@gasper-vrhovsek Yes, please wait for #40 to get merged.

@miq-bot
Copy link
Member

miq-bot commented Nov 21, 2017

This pull request is not mergeable. Please rebase and repush.

@gasper-vrhovsek gasper-vrhovsek force-pushed the feature/security_protocol_pretty_error branch from 8a272b6 to 7e572a4 Compare November 21, 2017 20:58
@gberginc gberginc self-assigned this Nov 21, 2017
@gasper-vrhovsek gasper-vrhovsek force-pushed the feature/security_protocol_pretty_error branch from 7e572a4 to bff6abe Compare November 21, 2017 21:01
@juliancheal
Copy link
Member

@gberginc This PR looks good to go. Agree?

@miq-bot
Copy link
Member

miq-bot commented Dec 13, 2017

@gasper-vrhovsek unrecognized command 'bug', ignoring...

Accepted commands are: add_label, assign, close_issue, move_issue, remove_label, rm_label, set_milestone

…rotocol

This change modifies the error message returned from nuage when selecting
the wrong security protocol. The old error message was: 'wrong status line:
"\x15\x03\x03\x00\x02\x02"' which was not informative to the end user.
Also added rspec test case to cover this exception.
@gasper-vrhovsek gasper-vrhovsek force-pushed the feature/security_protocol_pretty_error branch from bff6abe to 888f133 Compare December 14, 2017 14:32
@gasper-vrhovsek
Copy link
Contributor Author

As agreed with @gberginc i have changed the exception type and added a rspec test case which covers the exception tranlsation.

@miq-bot
Copy link
Member

miq-bot commented Dec 14, 2017

Checked commit gasper-vrhovsek@888f133 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🏆

Copy link
Contributor

@gberginc gberginc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliancheal this now LGTM

@@ -35,6 +35,8 @@ def translate_exception(err)
MiqException::MiqHostError.new("Socket error: #{err.message}")
when MiqException::MiqInvalidCredentialsError, MiqException::MiqHostError
err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problematic error that you mention in the commit msg is returned from the else part otherwise? I am reluctant to use this when case here as it relies on a generic http error message.

Furthermore, do you need to return HTTPBadResponse? In case we need this specific error message, I would still use the same error type as in the else part.

@juliancheal I’ve looked some other providers but couldn’t find any similar error oath - do you think it is necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gberginc yes, the problematic error is otherwise returned in the last else statement. And because the error message in the HTTPBadResponse is so poorly written, it has very little meaning showing it to the user through a dashboard error notification.

Copy link
Contributor

@gberginc gberginc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bronaghs bronaghs merged commit 8ac64a6 into ManageIQ:master Dec 18, 2017
@bronaghs bronaghs added this to the Sprint 76 Ending Jan 1, 2018 milestone Dec 18, 2017
simaishi pushed a commit that referenced this pull request Dec 19, 2017
…_pretty_error

Human readable error when selecting wrong security protocol
(cherry picked from commit 8ac64a6)
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit 110b7a78f5b99c2536bb83f4a2a33284e9aee3fe
Author: Bronagh Sorota <[email protected]>
Date:   Mon Dec 18 12:25:16 2017 -0500

    Merge pull request #43 from gasper-vrhovsek/feature/security_protocol_pretty_error
    
    Human readable error when selecting wrong security protocol
    (cherry picked from commit 8ac64a6b09e73bc3a78b8c8ef621b1f70e32c72e)

@gasper-vrhovsek gasper-vrhovsek deleted the feature/security_protocol_pretty_error branch December 19, 2017 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants